package com.tone.ji_volunteer.mapper;

import com.tone.ji_volunteer.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author tone(ang)
 * version 1.0
 */
@Mapper
public interface UserMapper {
    @Select("select id, nickname, gender, openid, perSig from ji_volunteer.user where openid = #{openid}")
    public User select(String openid);
    @Insert("insert into ji_volunteer.user(nickname, gender, openid, perSig) " +
            "values (#{nickname}, #{gender}, #{openid}, #{perSig})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    public void addUser(User user1);
    @Update("update ji_volunteer.user set gender = #{gender}, " +
            "nickname = #{nickname}, perSig = #{perSig} where openid = #{openid}")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    public void update(User user1);
    @Select("select nickname from ji_volunteer.user where " +
            "id in (select user_id from ji_volunteer.participate where act_id = #{activityId})")
    List<String> getAllParticipants(Integer activityId);
}
